﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></meta><style>/*<![CDATA[*/

table{border: 1px solid gray;}
td{border: 1px dotted gray;}
p{margin: 3px 0 3px 0; padding: 0;}
#ID_Footer{font-size: small; font-style: italic; text-align: right; margin-top: 4em; padding-top: 4px; border-top: 2px solid gray;}

/*]]>*/</style><title>08. 09. ThinkPHP 3.1.2 查询方式的一般使用1 2</title></head><body>
<div><br /></div>
<div><span style="font-family: 微软雅黑; font-size: 14pt; line-height: 140%">本节课大纲：</span></div>
<div><br /></div>
<div><span style="font-family: 微软雅黑; font-size: 12pt; font-weight: bold; line-height: 190%">一、普通查询方式</span></div>
<div><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp;a、</span><span style="font-family: 微软雅黑; font-size: 10pt; font-weight: bold; color: #ff0000; line-height: 140%">字符串</span></div>
<div><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$arr=$m-&gt;where(&quot;sex=0 </span><span style="font-family: 微软雅黑; font-size: 10pt; font-weight: bold; line-height: 140%">and </span><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 140%">username=&apos;gege&apos;&quot;)-&gt;find(); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span></div>
<div><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//有where，find可为空，返回数组</span></div>
<div><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 190%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//不推荐使用</span></div>
<div><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp;b、</span><span style="font-family: 微软雅黑; font-size: 10pt; font-weight: bold; color: #ff0000; line-height: 140%">数组</span></div>
<div><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$data[&apos;sex&apos;]=0;</span></div>
<div><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$data[&apos;username&apos;]=&apos;gege&apos;;</span></div>
<div><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$arr=$m-&gt;where($data)-&gt;find();</span></div>
<div><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 190%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//注意：这种方式默认是</span><span style="font-family: 微软雅黑; font-size: 10pt; font-weight: bold; line-height: 190%">and</span><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 190%">的关系，如果使用or关系，需要添加数组值</span></div>
<div><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;添加$data中的值，指明条件的逻辑关系为&apos;or&apos;</span></div>
<div><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$data[&apos;sex&apos;]=0;</span></div>
<div><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$data[&apos;username&apos;]=&apos;gege&apos;;</span></div>
<div><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$data[&apos;</span><span style="font-family: 微软雅黑; font-size: 10pt; font-weight: bold; color: #ff0000; line-height: 140%">_logic</span><span style="font-family: 微软雅黑; font-size: 10pt; color: #000000; line-height: 140%">&apos;]=&apos;or&apos;;</span></div>
<div><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 240%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//推荐使用，安全性较好，效率较高</span></div>
<div><span style="font-family: 微软雅黑; font-size: 12pt; font-weight: bold; line-height: 190%">二、表达式查询方式</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 140%">$data[&apos;id&apos;]=</span><span style="font-family: 微软雅黑; font-size: 10pt; font-weight: bold; color: #ff0000; line-height: 140%">array</span><span style="font-family: 微软雅黑; font-size: 10pt; color: #000000; line-height: 140%">(&apos;lt&apos;,6); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//子数组</span></div>
<div><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp;$arr=$m-&gt;where($data)-&gt;select();</span></div>
<div><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 微软雅黑; font-size: 10pt; font-weight: bold; color: #ff0000; line-height: 140%">EQ &nbsp; &nbsp;</span><span style="font-family: 微软雅黑; font-size: 10pt; color: #000000; line-height: 140%">等于</span></div>
<div><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 微软雅黑; font-size: 10pt; font-weight: bold; color: #ff0000; line-height: 140%">NEQ </span><span style="font-family: 微软雅黑; font-size: 10pt; color: #000000; line-height: 140%">不等于</span></div>
<div><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 微软雅黑; font-size: 10pt; font-weight: bold; color: #ff0000; line-height: 140%">GT &nbsp; &nbsp;</span><span style="font-family: 微软雅黑; font-size: 10pt; color: #000000; line-height: 140%">大于</span></div>
<div><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 微软雅黑; font-size: 10pt; font-weight: bold; color: #ff0000; line-height: 140%">EGT &nbsp;</span><span style="font-family: 微软雅黑; font-size: 10pt; color: #000000; line-height: 140%">大于等于</span></div>
<div><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 微软雅黑; font-size: 10pt; font-weight: bold; color: #ff0000; line-height: 140%">LT &nbsp; &nbsp; </span><span style="font-family: 微软雅黑; font-size: 10pt; color: #000000; line-height: 140%">小于</span></div>
<div><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 190%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 微软雅黑; font-size: 10pt; font-weight: bold; color: #ff0000; line-height: 190%">ELT &nbsp; </span><span style="font-family: 微软雅黑; font-size: 10pt; color: #000000; line-height: 190%">小于等于</span></div>
<div><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 微软雅黑; font-size: 10pt; font-weight: bold; color: #ff00ff; line-height: 140%">LIKE &nbsp;</span><span style="font-family: 微软雅黑; font-size: 10pt; color: #000000; line-height: 140%">模糊查询</span></div>
<div><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$data[&apos;username&apos;]=array(&apos;like&apos;,&apos;</span><span style="font-family: 微软雅黑; font-size: 10pt; font-weight: bold; color: #ff0000; line-height: 140%">%</span><span style="font-family: 微软雅黑; font-size: 10pt; color: #000000; line-height: 140%">ge&apos;);</span></div>
<div><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$arr=$m-&gt;where($data)-&gt;select();</span></div>
<div><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 微软雅黑; font-size: 10pt; font-weight: bold; color: #ff00ff; line-height: 140%">NOTLIKE</span></div>
<div><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$data[&apos;username&apos;]=array(&apos;notlike&apos;,&apos;%ge%&apos;);  &nbsp; &nbsp; &nbsp; &nbsp;//notlike</span><span style="font-family: 微软雅黑; font-size: 10pt; font-weight: bold; line-height: 140%">中间没有空格</span></div>
<div><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$arr=$m-&gt;where($data)-&gt;select();</span></div>
<div><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp;注意：如果一个字段要匹配多个通配符，多个配符再组成子子数组</span></div>
<div><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$data[&apos;username&apos;]=array(&apos;like&apos;,</span><span style="font-family: 微软雅黑; font-size: 10pt; font-weight: bold; color: #ff0000; line-height: 140%">array</span><span style="font-family: 微软雅黑; font-size: 10pt; color: #000000; line-height: 140%">(&apos;%ge%&apos;,&apos;%2%&apos;,&apos;%五%&apos;),</span><span style="font-family: 微软雅黑; font-size: 10pt; font-weight: bold; color: #ff0000; line-height: 140%">&apos;and&apos;</span><span style="font-family: 微软雅黑; font-size: 10pt; color: #000000; line-height: 140%">);</span></div>
<div><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//如果没有第三个值，默认关系是</span><span style="font-family: 微软雅黑; font-size: 10pt; font-weight: bold; color: #0000ff; line-height: 140%">or关系</span></div>
<div><span style="font-family: 微软雅黑; font-size: 10pt; color: #000000; line-height: 190%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$arr=$m-&gt;where($data)-&gt;select();</span></div>
<div><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 微软雅黑; font-size: 10pt; font-weight: bold; color: #ff0000; line-height: 140%">BETWEEN</span></div>
<div><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$data[&apos;id&apos;]=array(&apos;between&apos;, array(5,7));</span></div>
<div><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$arr=$m-&gt;where($data)-&gt;select();</span></div>
<div><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//SELECT * FROM `tp_user` WHERE ( (`id` BETWEEN 5 AND 7 ) )</span></div>
<div><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 微软雅黑; font-size: 10pt; font-weight: bold; color: #ff0000; line-height: 140%">NOT BETWEEN</span></div>
<div><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$data[&apos;id&apos;]=array(&apos;not between&apos;,array(5,7)); &nbsp; &nbsp; &nbsp; &nbsp;//注意，not 和 between</span><span style="font-family: 微软雅黑; font-size: 10pt; font-weight: bold; line-height: 140%">中间一定要有空格</span></div>
<div><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 240%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$arr=$m-&gt;where($data)-&gt;select();</span></div>
<div><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 微软雅黑; font-size: 10pt; font-weight: bold; color: #ff0000; line-height: 140%">IN</span></div>
<div><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$data[&apos;id&apos;]=array(&apos;in&apos;, array(4,6,7));</span></div>
<div><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$arr=$m-&gt;where($data)-&gt;select();</span></div>
<div><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//SELECT * FROM `tp_user` WHERE ( `id` IN (4,6,7) )</span></div>
<div><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 微软雅黑; font-size: 10pt; font-weight: bold; color: #ff0000; line-height: 140%">NOT IN</span></div>
<div><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$data[&apos;id&apos;]=array(&apos;not in&apos;, array(4,6,7)); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//not 和 in之间也</span><span style="font-family: 微软雅黑; font-size: 10pt; font-weight: bold; line-height: 140%">要有空格</span></div>
<div><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$arr=$m-&gt;where($data)-&gt;select();</span></div>
<div><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 240%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//SELECT * FROM `tp_user` WHERE ( `id` NOT IN (4,6,7) )</span></div>
<div><span style="font-family: 微软雅黑; font-size: 12pt; font-weight: bold; line-height: 190%">三、区间查询</span></div>
<div><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp;$data[&apos;id&apos;]=array(array(&apos;gt&apos;,4),array(&apos;lt&apos;,10)); &nbsp;</span></div>
<div><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//默认关系是</span><span style="font-family: 微软雅黑; font-size: 10pt; font-weight: bold; line-height: 140%"> and</span><span style="font-family: 微软雅黑; font-size: 10pt; color: #000000; line-height: 140%"> 的关系</span></div>
<div><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 190%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//SELECT * FROM `tp_user` WHERE ( (`id` &gt; 4) AND (`id` &lt; 10) ) </span></div>
<div><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp;$data[&apos;id&apos;]=array(array(&apos;gt&apos;,4),array(&apos;lt&apos;,10),&apos;</span><span style="font-family: 微软雅黑; font-size: 10pt; font-weight: bold; line-height: 140%">or</span><span style="font-family: 微软雅黑; font-size: 10pt; color: #000000; line-height: 140%">&apos;) </span></div>
<div><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 190%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//关系就是or的关系</span></div>
<div><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp;$data[&apos;name&apos;]=array(array(&apos;like&apos;,&apos;%2%&apos;),array(&apos;like&apos;,&apos;%五%&apos;),&apos;gege&apos;,&apos;or&apos;);</span></div>
<div><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 240%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//等于，直接写&quot;gege&quot;，不是用array(&apos;like&apos;, array(&apos;%2%2, %五%&apos;));</span></div>
<div><span style="font-family: 微软雅黑; font-size: 12pt; font-weight: bold; line-height: 190%">四、统计查询</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp;count //获取个数</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$m = M(&apos;User);</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$m-&gt;count(); &nbsp; &nbsp; &nbsp; &nbsp;//返回记录数</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 190%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$m-&gt;where(&apos;username=&quot;gege&quot;&apos;)-&gt;count();</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp;max &nbsp; //获取最大数</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 190%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$m-&gt;max(&apos;ID&apos;);</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp;min &nbsp; //获取最小数</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 190%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$m-&gt;min(&apos;ID&apos;);</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp;avg &nbsp; //获取平均数</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 190%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$m-&gt;avg(&apos;ID&apos;);</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp;sum &nbsp; //获取总和</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 240%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$m-&gt;sum(&apos;ID&apos;);</span></div>
<div><span style="font-family: 微软雅黑; font-size: 12pt; font-weight: bold; line-height: 190%">五、SQL直接查询</span></div>
<div><span style="font-family: 微软雅黑; font-size: 9pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 140%">a、</span><span style="font-family: 微软雅黑; font-size: 10pt; font-weight: bold; color: #ff0000; line-height: 140%">query </span><span style="font-family: 微软雅黑; font-size: 10pt; color: #000000; line-height: 140%">主要用于处理读取数据</span></div>
<div><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;成功返回数据的</span><span style="font-family: 微软雅黑; font-size: 10pt; font-weight: bold; line-height: 140%">结果集</span></div>
<div><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;失败返回</span><span style="font-family: 微软雅黑; font-size: 10pt; font-weight: bold; line-height: 140%">boolean false</span></div>
<div><span style="font-family: 微软雅黑; font-size: 10pt; padding-left: 40pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$m=M();</span></div>
<div><span style="font-family: 微软雅黑; font-size: 10pt; padding-left: 40pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$result=$m-&gt;query(&quot;select * &nbsp;from tp_user where id &gt;50&quot;);</span></div>
<div><span style="font-family: 微软雅黑; font-size: 10pt; padding-left: 40pt; line-height: 240%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;var_dump($result);</span></div>
<div><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp;b、</span><span style="font-family: 微软雅黑; font-size: 10pt; font-weight: bold; color: #ff0000; line-height: 140%">execute </span><span style="font-family: 微软雅黑; font-size: 10pt; color: #000000; line-height: 140%">用于更新和写入操作</span></div>
<div><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;成功返回</span><span style="font-family: 微软雅黑; font-size: 10pt; font-weight: bold; line-height: 140%">影响行数</span></div>
<div><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;失败返回</span><span style="font-family: 微软雅黑; font-size: 10pt; font-weight: bold; line-height: 140%">boolean false</span></div>
<div><span style="font-family: 微软雅黑; font-size: 10pt; padding-left: 40pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$m=M();</span></div>
<div><span style="font-family: 微软雅黑; font-size: 10pt; padding-left: 40pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$result=$m-&gt;execute(&quot;insert into tp_user(`username`) values(&apos;ztz3&apos;)&quot;);</span></div>
<div><span style="font-family: 微软雅黑; font-size: 10pt; padding-left: 40pt; line-height: 140%"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;var_dump($result);</span></div>
<div><br /></div>
<div><br /></div>
<div><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 140%">+++++++++++++++++++++++++++++++++++++++++Leo+++++++++++++++++++++++++++++++++++++</span></div>
<div><span style="font-family: 微软雅黑; font-size: 10pt; line-height: 140%">1. find 返回数组，只查询一条，select可以查多条</span></div>
<div><br /></div>
<div><br /></div>
<div><br /></div>
<div><br /></div>
<div><br /></div>
<div><br /></div>
<div><br /></div>
<div><br /></div>
<div><br /></div>
<div><br /></div>
<div><br /></div>
<div><br /></div>
<div><br /></div>
<div><br /></div>
<div><br /></div>
<div><br /></div>
<div><br /></div>
<div><br /></div>
<div><br /></div><script type="text/javascript" language="javascript" src="jquery.js"></script><script type="text/javascript" language="javascript" src="itemlink.js"></script></body></html>